/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.chw.calculator;

/**
 *
 * @author JSJSYS
 */
public class Calculator {
    double value = 0;
    
    void add(double num){
        value+=num;
        
    }
    
    
    void jian(double num){
        if(value==0){
            value=num;
        }else{
            value-=num;
        }
        
        
    }
    
    
    void cheng(double num){
         if(value==0){
            value=num;
        }else{
            value*=num;
        }
    }
    
    
    void chu(double num){
        try{
            
         if(value==0){
                value=num;
            }else{
                value/=num;
            }
            
        }catch(Exception e){
            // TODO
        }
            
    }
    public double getValue() {
        return value;
    }
    public double Clear() {
        return value=0;
    }
}
